/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
// prect.hpp - PegRect definition
//
// Author: Kenneth G. Maxwell
//         Jim DeLisle
//
// Copyright (c) 1997-2004 Swell Software 
//              All Rights Reserved.
//
// Unauthorized redistribution of this source code, in whole or part,
// without the express written permission of Swell Software
// is strictly prohibited.
//
// Notes:
// 
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

#ifndef _PEGRECT_
#define _PEGRECT_

struct PegRect
{
    void Set(PEGINT x1, PEGINT y1, PEGINT x2, PEGINT y2)
    {
        Left = (PEGSHORT) x1;
        Top = (PEGSHORT) y1;
        Right = (PEGSHORT) x2;
        Bottom = (PEGSHORT) y2;
    }

    void Set(PegPoint ul, PegPoint br)
    {
        Left = ul.x;
        Top = ul.y;
        Right = br.x;
        Bottom = br.y;
    }
    PEGBOOL Contains(PegPoint Test) const;
    PEGBOOL Contains(PEGINT x, PEGINT y) const;
    PEGBOOL Contains(const PegRect &Rect) const;
    PEGBOOL Overlap(const PegRect &Rect) const;
    void MoveTo(PEGINT x, PEGINT y);
    void Shift(PEGINT xShift, PEGINT yShift);
    PegRect operator &=(const PegRect &Other);
    PegRect operator |= (const PegRect &Other);
    PegRect operator &(const PegRect &Rect) const;
    PegRect operator ^= (const PegRect &Rect);
    PegRect operator +(const PegPoint &Point) const; 
    PegRect operator ++(int);
    PegRect operator += (int x);
    PegRect operator --(int);
    PegRect operator -= (int x);
    PEGBOOL operator != (const PegRect &Rect) const;
    PEGBOOL operator == (const PegRect &Rect) const;
                     
    PEGINT Width(void) const {return (Right - Left + 1);}
    PEGINT Height(void) const { return (Bottom - Top + 1);}

    PEGSHORT Left;
    PEGSHORT Top;
    PEGSHORT Right;
    PEGSHORT Bottom;
};

#endif

